Skip to content

fix(state): record (compose, overlay) pairs — stop reconstructing compose paths from overlay filenames#23

Merged
hefgi merged 1 commit into
mainfrom
claude/magical-einstein-7m4g40-overlays
Jun 11, 2026
Merged

fix(state): record (compose, overlay) pairs — stop reconstructing compose paths from overlay filenames#23
hefgi merged 1 commit into
mainfrom
claude/magical-einstein-7m4g40-overlays

Conversation

@hefgi

@hefgi hefgi commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Fixes #9

Problem

State recorded overlay file paths only; at teardown, the compose file each overlay belongs to was reconstructed by parsing the overlay filename (compose_file_for_overlay splits on the last hyphen and treats the suffix as a subdirectory). Slugs contain hyphens, so this is ambiguous:

  • slug feat-worker, root overlay feat-worker.yml, repo contains worker/docker-compose.yml (exactly the multi-compose layout this code serves) → the root overlay is torn down against worker/docker-compose.yml; the actual services keep running
  • the existing test for the "root overlay" case passes for the wrong reason: feat-foo does contain a hyphen — it returns None only because root/foo/ doesn't exist in the fixture

Fix

Stop encoding semantics in filenames. Session gains:

pub struct ComposeOverlay { pub compose: String, pub overlay: String }
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub compose_overlays: Vec<ComposeOverlay>,
  • bring_up (container + hybrid, both group-loop and single-compose paths) records each pair as it brings the group up
  • bring_down iterates the pairs directly: compose down -f <compose> -f <overlay>, then removes the overlay file

Compatibility, both directions:

  • the legacy overlay_file/overlay_files fields are still written, so an older binary can tear down sessions created by this version
  • state files without compose_overlays (older sessions) fall back to the legacy filename-based path, now clearly marked as legacy-only in modes/mod.rs

Tests

cargo fmt --check, cargo clippy -- -D warnings, cargo test (372 + 18) green.

https://claude.ai/code/session_017UcuvzMKHVfyBCcq8ipAko


Generated by Claude Code

…enames at teardown

Teardown reconstructed each overlay's compose file by splitting the
overlay filename on its last hyphen — ambiguous for hyphenated slugs.
A root overlay 'feat-worker.yml' in a repo that also has
worker/docker-compose.yml was torn down against the wrong compose file,
leaving services running.

Sessions now persist explicit (compose, overlay) pairs in a
compose_overlays field, written at bring_up and used directly by
bring_down. Legacy fields are still written so older binaries can tear
down new sessions, and state files without the new field fall back to
the old filename-based path, so existing sessions keep working.

Fixes #9

https://claude.ai/code/session_017UcuvzMKHVfyBCcq8ipAko
@hefgi hefgi merged commit b29d97f into main Jun 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overlay→compose mapping is reconstructed by filename parsing at teardown — ambiguous with hyphenated slugs; store the pairs in state

2 participants